home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
prog
/
iconp.zip
/
I$PSORT.ICN
< prev
next >
Wrap
Text File
|
1987-05-29
|
1KB
|
48 lines
# I-PSORT(1)
#
# Sort Icon procedures and declarations
#
# Ralph E. Griswold
#
# Last modified 4/27/83
#
procedure main()
local line, x, i, proctable, proclist, comments
comments := []
proctable := table()
while line := read() do {
if line ? {
="procedure" & # procedure declaration
tab(many(" ")) &
proctable[tab(upto("("))] := x := []
} then {
while put(x,get(comments)) # save it
put(x,line)
i := 1
while line := read() do {
put(x,line)
if line == "end" then break
}
}
# other declarations
else if line ? =("global" | "record" | "external")
then {
while write(get(comments))
write(line)
}
else put(comments,line)
}
while write(get(comments))
proclist := sort(proctable) # sort procedures
if *proclist > 1 then
every i := 1 to *proclist do # get main procedure to front
if proclist[i][1] == "main" then {
proclist := proclist[i+:1] ||| proclist[1:i] ||| proclist[i + 1:0]
break
}
every x := !proclist do { # output procedures
every write(!(x[2]))
}
end